package com.yuzhihao.writejvm.attributes.stack.verification;

import com.yuzhihao.writejvm.clazz.ClassInfo;
import com.yuzhihao.writejvm.read.Parse;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.log4j.Log4j2;

import java.io.DataInputStream;
import java.io.IOException;

/**
 *
 * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.4">jvmdoc</a>
 * @author yzh
 * @since 2021年12月14日13:46:15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Log4j2
public class UninitializedVariableInfo extends VerificationTypeInfo {

    private String tag = "ITEM_Uninitialized";

    private int offset_u2 = 2;

    private int offset = 2;

    private ClassInfo ci;

    @Override
    public void parse(DataInputStream dis, ClassInfo ci) {
        this.setCi(ci);

        try {
            this.offset = Parse.byteToInt(this.offset_u2,dis);
        } catch (IOException e) {
            log.error(e);
        }
    }

    @Override
    public String print() {
        return "uninitialized";
    }
}
